package com.hgxd.mapper;

import com.hgxd.entity.pojo.SlaveHistory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hgxd.entity.res.ResQOQAnalysis;
import com.hgxd.entity.res.TotalElectricalEnergy;
import com.hgxd.entity.res.ResYOYVo;
import com.hgxd.entity.vo.SlaveHistoryMsgVo;
import com.hgxd.entity.vo.SlaveHistoryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 从机变量记录表 Mapper 接口
 * </p>
 *
 * @author fsd
 * @since 2023-10-18
 */
@Mapper
public interface SlaveHistoryMapper extends BaseMapper<SlaveHistory> {

    List<SlaveHistoryMsgVo> getTotalEnergyByHour(@Param("beginTime") LocalDateTime beginTime
            , @Param("endingTime") LocalDateTime endingTime
            , @Param("slaveId") Integer slaveId);

    List<SlaveHistoryMsgVo> queryByInfoDAY(SlaveHistoryVo form);

    List<SlaveHistoryMsgVo> queryByInfoMon(SlaveHistoryVo param);

    List<SlaveHistoryMsgVo> queryByInfoYear(SlaveHistoryVo param);

    /**
     * 获取同比数据
     *
     * @param yoyVo
     * @return
     */
    List<ResYOYVo> getYOY(@Param("name") String name, @Param("time") Integer time);

    Integer getTotalElectricityHistoryByDate(LocalDate yesterday);

    /**
     * 传入对应时间段和从机名称，查询对应当前能耗和之前能耗
     *
     * @param slaveNames     从机名称（集合）
     * @param nowBeginTime   当前开始时间
     * @param nowEndingTime  当前结束时间
     * @param lastBeginTime  之前开始时间
     * @param lastEndingTime 之前结束时间
     * @return 对应ResQOQAnalysis对象
     */
    List<ResQOQAnalysis> getQOQ(@Param("slaveNames") List<String> slaveNames
            , @Param("nowBeginTime") LocalDateTime nowBeginTime
            , @Param("nowEndingTime") LocalDateTime nowEndingTime
            , @Param("lastBeginTime") LocalDateTime lastBeginTime
            , @Param("lastEndingTime") LocalDateTime lastEndingTime);

    /**
     * 根据时间区间和从机名查询起始值，截至值以及差值
     *
     * @param slaveNames
     * @param beginTime
     * @param endingTime
     * @return
     */
    List<TotalElectricalEnergy> getElectricityByTimeAndName(@Param("slaveNames") List<String> slaveNames
            , @Param("beginTime") LocalDateTime beginTime
            , @Param("endingTime") LocalDateTime endingTime);

}
